@using System.Linq;
@{
    if(IsPost){
        AppState["Forms"] = Wufoo.GetWebHookData();
	}    
    
    dynamic FormData = AppState["Forms"];
}
    <h3>Wufoo.GetWebHookData() Method</h3>
   
<p>The GetWebHookData() method from the helper allows you to easily 
    retrieve the posted data from the WebHook integration. It returns a 
    data collection, from where you can access each form field and also
    some useful submission information (user IP address, creation date, etc.).</p>
              
    <p>For a complete reference on how to access each different type of field, see the helper reference page.</p>
    
    <h3>Usage:</h3>
    <pre class="codePre">@@{
        <strong>var FormData = Wufoo.GetWebHookData();</strong>
        
        // Access form creation data
        var createdAt = FormData.CreatedBy;
        
        // Access Single field values
        var fieldTitle = FormData.Fields["Field1"].Title;
        var fieldValue = FormData.Fields["Field1"].Value;

        // Iterate through fields collection
        &lt;ul&gt;
        @@foreach(var field in FormData.Fields.Values) {
            &lt;li&gt;@@field.ID&lt;/li&gt;
            &lt;li&gt;@@field.Value&lt;/li&gt;
            ...
        }
        &lt;/ul&gt;
    }</pre><br/>
    
    <h3>In Action:</h3>
   
@if(FormData != null){
                        
    <p>Below you can see all the data posted in the last form submission, retrieved with the GetWebHooksData() method.</p>
    <div>
        <dt>Created by:</dt><dl>@FormData.CreatedBy</dl>
        <dt>Date Created:</dt><dl>@FormData.DateCreated</dl>
        <dt>IP:</dt><dl>@FormData.Ip</dl>
        <dt>Handshake Key:</dt><dl>@FormData.HandshakeKey</dl>
    </div>
    <div style="clear:both;"></div>
    <h4>Fields:</h4>
    <table class="box">
        <thead>
        <tr>
            <th>Id</th>
            <th>Type</th>
            <th>Title</th>
            <th>Value</th>     
        </tr>
        </thead>
        <tbody>          
        @foreach (var field in FormData.Fields.Values) {
        <tr>
            <td>@field.ID</td>
            <td>@field.Type</td>
            <td>@field.Title</td>
            <td style="width:400px">                
                @if (field.Type == "radio" || field.Type == "select") {
                    @:|
                    foreach (dynamic choice in field.Choices) {
                        string choiceLabel = choice.Label.ToString();
                        if( (field.Value != null) && (choiceLabel.ToLower().Equals(field.Value.ToString().ToLower()) )) {
                            <b>@choiceLabel</b>
                        } else {
                            @choiceLabel
                        }
                        @:|
                     }                                          
                } else { 
                    @field.Value
                }                
             </td>
        </tr>
        }
    </tbody>          
    </table>
} else {
      <div class="message info">To be able to test the Wufoo.GetWebHookData() method you first need to submit one of your forms.</div>
}    